﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Cirrious.MvvmCross.Interfaces.ViewModels;
using Cirrious.MvvmCross.WinRT.Interfaces;
using TeaLightV5.Foundation.UX.ViewModels;
using Windows.UI.Xaml.Controls;

namespace TeaLightV5.Foundation.UX.WinRT.Views
{
    public class EntityPart<T> : UserControl
    {
        private IMvxViewModel _viewModel;
        public IMvxViewModel ViewModel
        {
            get { return _viewModel; }
            set
            {
                if (_viewModel == value)
                    return;

                _viewModel = value;
                DataContext = ViewModel;

                EntityViewModel baseViewModel = ViewModel as EntityViewModel;
                if (baseViewModel != null)
                {
                    // todo Refactor ReloadModel
                    baseViewModel.ReloadModel();
                }

            }
        }
    }
}
